package org.cttic.visualization.visualization.test;

//import org.cttic.visualization.visualization.common.esData_strip;
import com.alibaba.fastjson.JSONObject;
import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCursor;
import com.mongodb.client.model.Filters;
import org.bson.Document;
import org.cttic.visualization.visualization.common.commonConf;
import org.cttic.visualization.visualization.common.retSectionData;
import org.cttic.visualization.visualization.common.sectionBillQuery;
import org.cttic.visualization.visualization.util.DateUtil;
import org.cttic.visualization.visualization.util.ParseJsonDataUtil;
import org.cttic.visualization.visualization.z_service.impl.ElasticsearchOptionServerImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;


/**
 * @author shkstart
 * @create 2020-05-07 15:34
 */
public class test {
    @Autowired
    MongoTemplate mongoTemplate;
    public static void main(String[] args) throws ParseException {
        String date="2020-05-08 05:57:45";
        String month = date.substring(5, 7);
        String day = date.substring(8, 10);
        System.out.println("trip_info_2020"+month);

        /*
        http://192.168.114.119:9042/hmop/mmp/api/tb/getJiangXiNationalBilling?
        vehPlate=赣C2M052&plateColor=1&adminCode=36&sectionCode=S0061360010&
        sectionDirection=2&billMile=14.938&currentsTime=2020-4-21T12:12:14&
        vehCode=14&vehicleType=0&actualAxleNum=4&mediumType=2&tollIntervals=S006136001000420
         */
//        String vehPlate="赣C2M052";
//        int plateColor=1;
//        String adminCode="36";
//        String sectionCode="S0061360010";
//        String sectionDirection="2";
//        Float billMile=14.938F;
//        String currentsTime="2020-4-21T12:12:14";
//        int vehCode=14;
//        int vehicleType=0;
//        int actualAxleNum=4;
//        String mediumType="2";
//        String tollIntervals="S006136001000420";
//
////        String url ="http://192.168.114.119:9042/hmop/mmp/api/tb/getJiangXiNationalBilling?vehPlate=赣C2M052&plateColor=1&adminCode=36&sectionCode=S0061360010&sectionDirection=2&billMile=14.938&currentsTime=2020-4-21T12:12:14&vehCode=14&vehicleType=0&actualAxleNum=4&mediumType=2&tollIntervals=S006136001000420";
//        String urlString ="http://192.168.114.119:9042/hmop/mmp/api/tb/getJiangXiNationalBilling?vehPlate="+vehPlate+"&plateColor="+plateColor+"&adminCode="+adminCode+"&sectionCode="+sectionCode+"&sectionDirection="+sectionDirection+"&billMile="+billMile+ "&currentsTime="+currentsTime+"&vehCode="+vehCode+"&vehicleType="+vehicleType+"&actualAxleNum="+actualAxleNum+"&mediumType="+mediumType+"&tollIntervals="+tollIntervals;
//        System.out.println("urlString:"+urlString);
//        RestTemplate restTemplate = new RestTemplate();
//        ResponseEntity<String> responseEntity = restTemplate.getForEntity(urlString, String.class);
//        String body = responseEntity.getBody();
//        System.out.println(body);
//        retSectionData retSectionData = JSONObject.parseObject(body, retSectionData.class);
//        String billAmount = retSectionData.getData().getBillAmount();
//        System.out.println("billAmount:"+billAmount);
    }
    public void mongoTest(String vehPlate,String vehPlateColor,String endTime,String startTime){
        FindIterable<Document> documents = mongoTemplate.getDb().getCollection(commonConf.mongoStrip)
                .find(Filters.and(Filters.eq("vehicleNo", vehPlate),
                        Filters.eq("vehicleColor", Integer.parseInt(vehPlateColor)),
                        Filters.lte("gpsTime",endTime),
                        Filters.gte("gpsTime",startTime)));

        MongoCursor<Document> iterator = documents.iterator();
        while (iterator.hasNext()){
            String json = iterator.next().toJson();
            System.out.println(json);
//            JSONObject jsonData = ParseJsonDataUtil.getJsonData(json);
//            jsonData.getString()
        }
    }
}
